package com.candy.control;

import com.candy.service.UserInfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/updateUserInfo")
public class UserInfoUpdateServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("访问后台成功............");
//        设置字符集，处理中文乱码问题
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
//调用业务逻辑处理层进行业务处理
        UserInfoService userInfoService=new UserInfoService();
       String username= req.getParameter("username");
       String userpwd= req.getParameter("userpwd");
       String useraddress= req.getParameter("useraddress");
       String userTel=  req.getParameter("usertel");
       int isdelete=0;
        int userId=Integer.parseInt( req.getParameter("userid"));
//        调用修改方法将数据库中的数据进行修改
       userInfoService.updateUserInfo(username,userpwd,useraddress,userTel,isdelete,userId);
//         修改完成后进行页面跳转
       req.getRequestDispatcher("WEB-INF/userManger/userInfoQuery.jsp").forward(req,resp);





    }
}
